package q467_findSubstringInWraproundString;

public class Solution {
    public static void main(String[] args) {
        String a = "abc";
        System.out.println(a.substring(0,1));
    }
    public int findSubstringInWraproundString(String p) {
        int[] numsOfString = new int[26];
        int temp = 0;
        for (int i = 0; i < p.length(); i++) {
            if (i > 0 && (p.charAt(i) == p.charAt(i - 1) + 1 || (p.charAt(i) == 'a' && p.charAt(i - 1) == 'z'))) {
                temp ++;
            }else {
                temp = 1;
            }
            numsOfString[p.charAt(i) - 'a'] = Math.max(numsOfString[p.charAt(i) - 'a'], temp);
        }

        int ans = 0;
        for (int i = 0; i < numsOfString.length; i++) {
            ans += numsOfString[i];
        }
        return ans;
    }
}
